$(function(){

  // banner轮播图
  var myimg = ['dfa','asdf','asdf'];
  var timer = setInterval(move,1500);
  var speed = 0;
  function move(){
  	speed++;
  	if ( speed>myimg.length-1 ){
  		speed = 0;
  	}
    $( '.list>li' ).eq( speed ).addClass( 'lxz' ).siblings().removeClass( 'lxz' );
  	// $('.banner>img').attr('src',myimg[speed]);
      // 绑定动画
    var mysrc = $( '.banner>img' ).attr('src');
    var newsrc = 'images/index/index_03.png';
    if ( mysrc==newsrc ) {
      $( '.focusMid' ).css('display','block');
      $( '.focusLeft' ).css('display','block');
      $( '.focusTop' ).css('display','block');
      $( '.focusRight' ).css('display','block');
      $( '.focusBottom' ).css('display','block');
    }else{
      $( '.focusMid' ).css('display','none');
      $( '.focusLeft' ).css('display','none');
      $( '.focusTop' ).css('display','none');
      $( '.focusRight' ).css('display','none');
      $( '.focusBottom' ).css('display','none');
    }
  }
  //左箭头切换
  $( '.arrL' ).click(function(){
  	 speed--;
  	 if ( speed<0 ) {
  	 	speed = 2;
  	 }
     $( '.list>li' ).eq( speed ).addClass( 'lxz' ).siblings().removeClass( 'lxz' );
  	 $('.banner>img').attr('src',myimg[speed]);
  })

  //右箭头切换
   $( '.arrR' ).click(function(){

   	  speed++;
   	  if ( speed>3 ) {
   	  	speed=0;
   	  }
   	  $( '.list>li' ).eq( speed ).addClass( 'lxz' ).siblings().removeClass( 'lxz' );
   	  $('.banner>img').attr('src',myimg[speed]);
   })

   //底部按钮
   $( '.list>li' ).click(function(){

   	  $(this).addClass('lxz').siblings().removeClass( 'lxz' );

   	  $( '.banner>img' ).attr( 'src',myimg[ $(this).index() ] );

   })
  //底部闪烁按钮
   var timer1 = setInterval( move1,500);

   function move1(){

   	  var newlinght = $( '.light' ).css( 'opacity' );

   	  if ( newlinght == 1 ) {

   	  	 $( '.light' ).css( 'opacity',0 );
   	  
   	  }else{

   	  	  $( '.light' ).css( 'opacity',1 );
   	  }
   }
   
  // 清除计时器
   $( '.banner' ).mouseover(function(){
      $( '.arrL' ).show();
      $( '.arrR' ).show();
   	  clearInterval( timer );
   })

   //在次调用计时器
   $( '.banner' ).mouseout(function(){
      $( '.arrL' ).hide();
      $( '.arrR' ).hide();
      timer = setInterval(move,1500);

   })


   
   //关于我们
   $( window ).scroll(function(){

       var myHeight = $( window ).scrollTop();

       if (myHeight>1640){

          $( '.abTitil' ).css('transform','translateY(0)');
          $( '.minTittl' ).css('transform','translateY(0)');
          $( '.aboutUsText' ).css('transform','translateY(0)');
          $( '.abClickMoer' ).css('transform','translateY(0)');
       }

   })

   //我们的优势
   $( '.tit' ).click(function(){

       var cTimr = setInterval(cTmr,400);
       var  cd  = 0; 
       function cTmr(){

            ++cd;

        if (cd==1) {

           $( '.one' ).css('opacity','1');
           $( '.pic_one' ).css('opacity','1');

        }else if ( cd==2 ) {

           $( '.two' ).css('opacity','1');
           $( '.pic_two' ).css('opacity','1');

        }else if ( cd==3 ) {

           $( '.three' ).css('opacity','1');
           $( '.pic_three' ).css('opacity','1');

        }else if ( cd==4 ) {

           $( '.four' ).css('opacity','1');
           $( '.pic_four' ).css('opacity','1');

        }else if ( cd==5 ) {

           $( '.five' ).css('opacity','1');
           $( '.pic_five' ).css('opacity','1');

        }else if ( cd==6 ) {

           $( '.six' ).css('opacity','1');
           $( '.pic_six' ).css('opacity','1');

        }else if ( cd==7 ) {

           $( '.seven' ).css('opacity','1');
           $( '.pic_seven' ).css('opacity','1');

        }else{
           clearInterval(cTimr);
        }

       }
   

   })


  //服务Hover
   var serveList = document.getElementsByClassName('serveList')[0];
   var newli = serveList.getElementsByTagName('li');
   var newimg = serveList.getElementsByTagName('img');

   var newqihuan = document.getElementsByClassName('serveQiehuan')[0];
   var newqh = newqihuan.getElementsByTagName('img')[0];


   var imgShow = ['public/home/images/index/fw_03.png','public/home/images/index/fw_06.png','public/home/images/index/fw_08.png','public/home/images/index/fw_10.png'];
   var imgHover = ['public/home/images/index/hover_03.png','public/home/images/index/hover_06.png','public/home/images/index/hover_08.png','public/home/images/index/hover_10.png'];
   var imgQ = ['public/home/images/index/service_aaa.png','public/home/images/index/service_bbb.png','public/home/images/index/service_ccc.png','public/home/images/index/service_ddd.png'];
   
   for (var i = 0;i<imgShow.length;i++){
        
        newli[i].index = i ;
        
        newli[i].onmouseover=function(){

        	for (var j = 0; j<newli.length;j++){

                newimg[j].src = imgShow[j];
        	}
           newimg[this.index].src = imgHover[this.index];
           newqh.src = imgQ[this.index];
        }
   }
   

   //无缝滚动
   var newWidth = $( '.caseList' ).width()*2;
   $( '.caseList' ).css('width',newWidth);
   var Content = $( '.caseList' ).html();
   $( '.caseList' ).html( Content+Content );
 
   var timer2 = setInterval(slider,10);
   var cur = 1;

   function slider(){
        var newLeft = $( '.caseList' ).css( 'margin-left' );        
     if (newLeft>0+'px') {
         $( '.caseList' ).css( 'margin-left',-newWidth/2+'px' );
     }if (newLeft == -newWidth/2+'px'){
         $( '.caseList' ).css( 'margin-left',0+'px' );   
     }       
        $( '.caseList' ).css( 'margin-left','+='+cur+'px' );  
   }
   // 点击箭头切换滚动方向
   $( '.caseArrL' ).click( function(){
        cur = -1;
   } )
   $( '.caseArrR' ).click( function(){
       cur = 1;
   } )

   //鼠标移入清除和再次调用计时器
  $( '.caseBox' ).mouseover(function(){
      clearInterval(timer2); 
  })

  $( '.caseBox' ).mouseout(function(){
      timer2 = setInterval(slider,20);
  })

})